home *** CD-ROM | disk | FTP | other *** search
/ Professional Soft Collection 1.02 / Professional Soft Collection 1.02.iso / nu80 / aliases.__! / ALIASES
Text File  |  1994-04-23  |  10KB  |  243 lines

  1. :
  2. :                     ALIASES -- NDOS Sample Alias File
  3. :
  4. :
  5. :     The aliases in this file are designed to give you some examples of
  6. :     how NDOS aliases can be used and the power they have.  It is not
  7. :     intended to be an exhaustive list, and many of these may not be
  8. :     appropriate for your needs.  But they should give you a feel for how
  9. :     to use aliases to help get your work done.
  10. :
  11. :     CAUTION:  These aliases are EXAMPLES.  We do NOT promise that they
  12. :     will work properly when run on your system.  They are simply intended
  13. :     to show what's possible and give you a feel for how to write your
  14. :     own set of aliases.  You may find some of them useful, but others
  15. :     may fail or have unintended effects when they are run on a system
  16. :     other than the one they were designed for.
  17. :
  18. :     This file is designed to be loaded with an ALIAS /R command, for
  19. :     example:
  20. :
  21. :               alias /r aliases
  22. :
  23. :     You can also load aliases from a batch file, but ALIAS /R is much
  24. :     faster.  See the manual for more details on loading aliases.
  25. :
  26. :     We suggest you put your standard aliases in a self-contained
  27. :     file like this one which can be invoked from AUTOEXEC.  That
  28. :     way the file can also be re-invoked after it is edited, to re-
  29. :     install the aliases.
  30. :
  31. :
  32. :     The next few aliases set up some directory commands that provide
  33. :     shorthand ways to view the directory in several different formats
  34. :     (see the DIR command in the manual for more details).
  35. :
  36. :     Note that none of these aliases has any arguments specified (%1,
  37. :     %2, etc.).  This means that all arguments on the actual command line
  38. :     will be appended to the alias text.  For example:
  39. :
  40. :             d2 x*
  41. :
  42. :     is equivalent to:
  43. :
  44. :             dir /2pv x*
  45. :
  46. :     and:
  47. :
  48. :             d2 x* y* z*
  49. :
  50. :     is equivalent to:
  51. :
  52. :             dir /2pv x* y* z*
  53. :
  54. d2 dir /2pv
  55. de dir /oe
  56. dir *dir /p
  57. wh*ereis dir /dp
  58. :
  59. :     The last two commands above demonstrate the use of an asterisk to
  60. :     terminate alias expansion and to shorten the name of an alias.
  61. :
  62. :     In the first case, if the command were defined as:
  63. :
  64. :             alias dir dir/p
  65. :
  66. :     it would generate an alias loop error.  The inclusion of the "*"
  67. :     makes NDOS terminate alias expansion for that command, which
  68. :     allows the redefinition of a command with specific switch settings.
  69. :     In this case "dir" is redefined as "dir/p", which will cause
  70. :     directories to be displayed with a pause at the end of each page.
  71. :
  72. :     The "whereis" command demonstrates truncation of an alias name.
  73. :     The * is placed after the last required character in the name, so
  74. :     the "whereis" command can be entered as "wh", "whe", "wher",
  75. :     "where", "wherei", or "whereis".
  76. :
  77. :
  78. :     The following aliases are more shorthand:  DD and DU (directory
  79. :     down and directory up) for pushd and popd, DX (shows only the
  80. :     subdirectories, L for list, etc.
  81. :
  82. dd pushd
  83. du popd
  84. dx *dir /mwad
  85. l list
  86. clr mode mono
  87. :
  88. :     Aliases can also be used to modify the behavior of some internal
  89. :     commands.  The two examples below show how you can force DELETE and
  90. :     MOVE to prompt before execution.  If you need to use the unprompted
  91. :     command, use the leading asterisk ("*DEL").
  92. :
  93. del*ete *del /p
  94. move *move /r
  95. :
  96. :
  97. :     The next aliases show how some commands can be enhanced.  Instead of
  98. :     always prompting you for new values, TIME and DATE can simply report
  99. :     the current information.
  100. :
  101. date echo Today is %_dow %_date
  102. time echo The time is %_time
  103. :
  104. :     Here's what the next few aliases do:
  105. :
  106. :             more:   Uses the NDOS LIST /S as a substitute for the DOS MORE
  107. :                     command.  Note the use of the * to allow the command
  108. :                     to be entered as MO, MOR, or MORE
  109. :
  110. :             sdel:   Allows you to select files for deletion from a subset
  111. :                     of files as specified in the command argument.  For
  112. :                     example:
  113. :
  114. :                             sdel *.obj
  115. :
  116. :                     will allow you to select files to delete from a list
  117. :                     of all .obj files.  (See the SELECT command in the
  118. :                     manual for more details).
  119. :
  120. :             up:     Moves "up" in the directory tree, i.e. to the parent
  121. :                     directory.
  122. :
  123. :             ov:     Moves "over" in the directory tree, to another subdi-
  124. :                     rectory which has the same parent as the current
  125. :                     directory.
  126. :
  127. mo*re list /s
  128. sdel select del (%1)
  129. up cd ..
  130. ov cd ..\%1
  131. :
  132. :     The next two aliases show how arguments can be passed to commands.
  133. :     In both cases the argument given when the alias is invoked is passed
  134. :     to the program at the appropriate place in its command string.
  135. :
  136. lp lpr -u %1 >lpt1
  137. ps d:\peri\ps /t:%1 /e:4
  138. :
  139. :     The next few aliases demonstrate several things.  Some use the
  140. :     command separator character ^ to include multiple commands in
  141. :     the alias.  ND2 uses the "&&" (AND) operator so that the second
  142. :     command is only executed if the first was succcessful.  The last
  143. :     two (PC and BACK) use the alias called IN to do their job.  In
  144. :     fact IN was designed for "internal" use by other aliases in this
  145. :     file, though it could be used elsewhere as well.  Note that, while
  146. :     PX is set up before it is referenced in other aliases, this is not
  147. :     really necessary, because any command in one alias which refers to
  148. :     another is handled when the alias is invoked, not when it is set
  149. :     up with the alias command.
  150. :
  151. :     Here's what each alias does:
  152. :
  153. :             nd:     Creates a new directory below the current directory,
  154. :                     then changes to it.
  155. :
  156. :             nd2:    Attempts to create the specified directory on any
  157. :                     drive, then changes to it if the creation was
  158. :                     successful.
  159. :
  160. :             w:      Saves the current directory, changes to the ws
  161. :                     directory on drive c:, runs the ws program using
  162. :                     the first argument on the command line, and
  163. :                     restores the original directory when done.
  164. :
  165. :             zap:    Deletes all the .bak files in the current directory,
  166. :                     then does a wide directory listing.
  167. :
  168. :             in:     "Pushes" a different directory, executes a command,
  169. :                     including all of the arguments on the command line,
  170. :                     and then goes back to the original directory.  See
  171. :                     PUSHD, POPD, and Alias Parameters in the manual for
  172. :                     more details.
  173. :
  174. :             pc:     Changes to the \comm directory on drive c:, runs
  175. :                     the program called pca, then returns to the
  176. :                     drive and directory in use when the command was
  177. :                     executed.
  178. :
  179. :             back:   Changes to the \backup directory on drive d:, runs
  180. :                     the program called tape, then returns to the previous
  181. :                     drive and directory.
  182. :
  183. nd md %1^cd %1
  184. nd2 md %1 && *cdd %1
  185. w pushd c:\wp^ws %1^popd
  186. zap del *.bak^dir /w
  187. in pushd %1^%2&^popd
  188. pc in c:\comm pca
  189. back in d:\backup tape
  190. :
  191. :     The following aliases make use of the %& argument.  This argument
  192. :     means "all of the arguments on the command line".  For example:
  193. :
  194. :             zap2 *.bak *.lst *.bk!
  195. :
  196. :     expands to:
  197. :
  198. :             erase *.bak *.lst *.bk!^chkdsk^dir /w
  199. :
  200. :     The last of the three aliases below uses the %@eval function to
  201. :     create a command-line calculator, by simply passing all arguments
  202. :     on the command line to the function.
  203. :
  204. zap2 erase %&^chkdsk^dir /w
  205. ed edit %&^del *.bak
  206. cal*c echo The answer is:  %@eval[%&]
  207. :
  208. :     The following two aliases, taken from the manual, show how to
  209. :     combine alias with keystack to invoke a program and pass parameters
  210. :     to it.  See the manual for details on what they do.  Note that the
  211. :     0s in the keystack strings simulate an empty keyboard buffer; the
  212. :     13s are carriage returns.
  213. :
  214. 321 keystack 0 13 0 13 0 13 0 13 0 13 "/fr" 0 "%1" 13^123
  215. drpt pushd c:\data^keystack "use times index times" 13 "report form timerep to print" 13 "quit" 13^dbase^popd
  216. :
  217. :     The following aliases show the use of IFF in aliases.  The first
  218. :     redefines SET so that it displays the environment variables with a
  219. :     /P if no parameters are given, or processes the SET if parameters
  220. :     are specified.  The second checks whether the argument is a directory;
  221. :     if so it deletes the files in the directory and then removes the
  222. :     directory.  If not, it gives an error message.
  223. :
  224. set iff "%1"=="" then *set /p ^ else *set %& ^ endiff
  225. zap iff isdir %1 then ^ *del %1 ^ *rd %1 ^ else ^ beep ^ echo Not a directory! ^ endiff
  226. :
  227. :     You can also assign any alias to a keystroke to save a lot of typing.
  228. :     Check your manual for the proper way to express keynames.
  229. :
  230. :     The following examples reassign the following keys:
  231. :
  232. :        F5:        wide directory
  233. :           Ctrl-F1    clear screen
  234. :           Shift-F10: "EXIT" + ENTER  (useful when "shelling out")
  235. :           Alt-F1:    invokes another HELP program
  236. :
  237. @f5 dir /w
  238. @Ctrl-F1 cls
  239. @shift-f10 exit r
  240. @alt-f1 c:\dos\help
  241.  
  242. 
  243.